﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace RM.BasicLibrary.Resources
{
    public class Resource
    {
        /// <summary>
        /// 中文
        /// </summary>
        public static readonly string CH = "zh-CN";
        /// <summary>
        /// 英文
        /// </summary>
        public static readonly string EN = "en-US";
        /// <summary>
        /// 初始对象为中文
        /// </summary>
        public Resource()
        {

        }
        /// <summary>
        /// en-US \ zh-CN
        /// </summary>
        /// <param name="language"></param>
        public void SetLanguage(string language)
        {
#if NET46 || NETCOREAPP
            CultureInfo.CurrentCulture = new CultureInfo(language);
            CultureInfo.CurrentUICulture = new CultureInfo(language);
            Thread.CurrentThread.CurrentCulture = new CultureInfo(language);
#endif
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(language);
        }
        /// <summary>
        /// 获取资源文件对象
        /// </summary>
        /// <param name="key"></param>
        /// <param name="arg"></param>
        /// <returns></returns>
        public string GetValue(string key, params object[] arg)
        {
            return string.Format(Thread.CurrentThread.CurrentUICulture, key, arg);
        }
    }
}
